1 // Equipo Poncho, Carriel y Ruana
22 template <class T
> string
toStr(const T
&x
)
23 { stringstream s
; s
<< x
; return s
.str(); }
24 template <class T
> int toInt(const T
&x
)
25 { stringstream s
; s
<< x
; int r
; s
>> r
; return r
; }
27 #define For(i, a, b) for (int i=(a); i<(b); ++i)
28 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
29 #define D(x) cout << #x " = " << (x) << endl;
31 const double EPS
= 1e-9;
33 int cmp(double x
, double y
= 0, double tol
= EPS
) {
34 return (x
<= y
+ tol
) ? (x
+ tol
< y
) ? -1 : 0 : 1;
37 #define INPUT_FILE "jay"
40 const int MAXB
= MAXN
* MAXN
;
47 freopen(INPUT_FILE
".in", "r", stdin
);
54 cin
>> tiempo
[i
] >> bolas
[i
];
55 totalBolas
+= bolas
[i
];
57 for (int b
= 0; b
<= totalBolas
; ++b
) dp
[n
][b
] = 0;
58 for (int i
= n
- 1; i
>= 0; --i
) {
59 for (int b
= 0; b
<= totalBolas
; ++b
) {
60 dp
[i
][b
] = dp
[i
+ 1][b
+ bolas
[i
]] + tiempo
[i
];
62 int option
= dp
[i
+ 1][b
- 1 + bolas
[i
]] + tiempo
[i
] / 2;
63 if (option
< dp
[i
][b
]){
69 cout
<< dp
[0][0] << endl
;